var ishistory = false;
$(document).ready(function(){
	
	//待上传文件列表，只存储合法有效且在编号在数据库有对应的文件名。
	var fileUploadList = [];
	//上传文件成功列表名
	var fileSucList = [];
	//文件名正则表达式 类似'000109-A-0001'这种格式
	var fileRge = /\w+-[a-zA-Z]-\w+/g;
	
	$("#functionNav").attr("href",navAddr);
	//获取并填充来源类型
	var lylxJson = ajaxResult("get",false,ProjectName+"/sysmanage.getIdAndNameInJb.do",{'tableName':'jb_lyfs'});
	loadSelect("#form1 select[name=lylx]",lylxJson.rows,'id','name');
	//获取并填充时代
	getSdOption();
	//var doms_sd = ["DJH_SD1","DJH_SD2","DJH_SD3","DJH_SD4"];
	//selectFour(url_nd,doms_sd);
	//获取查询条件
	var params =$("#form1").serializeObject();
	if(getUserRight()){
		params["sysid"]=userInfo.userid;
		//初始化待上传影像Table
	  	createTable('#dbTable',ProjectName+'/imageManage.getImageList.do','id',tblColTitle,params);
	}	
	
 	 //点击查询按钮
	 $("#search_btn").click(function(){
		 refreshTable('#dbTable','#form1');
	 });
	 $("#plsc_btn").click(function(){
		 window.location.href='imageImport.html';
	 });
})
function delImage(id){
	bootbox.setLocale("zh_CN");
	bootbox.confirm("影像删除后将不能恢复，确定要删除吗？",function(r){
		if(r){
			var dbResult = ajaxResult("post",false,ProjectName+"/imageManage.delImage.do",{"id":id});
			if(dbResult["status"] == 'ok'){
			   alertFunc("影像删除成功！");
			   $('#dbTable').bootstrapTable('refresh');
		    }else{
			   alert(dbResult["error"]);
		    }
		}
	});
}
var tblColTitle = [{
	        field: 'zdjh',
	        title: '总登记号'
	    }, {
	        field: 'cpmc',
	        title: '藏品名称'
	    }, {
	        field: 'yxmc',
	        title: '影像名称'
	    }, {
	        field: 'sd4',
	        title: '时代',
	        formatter: function(value, row, index) {
	        	var sd="";
	        	if(row.sd4!="" && row.sd4!=null){
	        		sd =row.sd4;
	        	}else if(row.sd3!="" && row.sd3!=null){
	        		sd =row.sd3;
	        	}else if(row.sd2!="" && row.sd2!=null){
	        		sd =row.sd2;
	        	}else if(row.sd1!="" && row.sd1!=null){
	        		sd =row.sd1;
	        	}
	        	return sd;
		      }
	    }, {
	        field: 'sjsl',
	        title: '实际数量',
	        formatter: function(value, row, index) {	        	
	        	return value+row.sjsldw;
		      }
	    }, {
	        field: 'lylx',
	        title: '来源方式'
	    },{
	        field: '',
	        title: '操作',
	        formatter: function(value, row, index) {
	      	  		return '<a href="#" onclick="delImage('+row.id+')">删除影像</a>';
		      }
	    }];


